package com.qtt.app.mapper;

import com.qtt.app.entity.AppStudyHistory;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository

public interface AppStudyHistoryMapper {
    int deleteByPrimaryKey(Integer studyHistoryId);

    int insert(AppStudyHistory record);

    int insertSelective(AppStudyHistory record);

    AppStudyHistory selectByPrimaryKey(Integer studyHistoryId);

    int updateByPrimaryKeySelective(AppStudyHistory record);

    int updateByPrimaryKeyWithBLOBs(AppStudyHistory record);

    int updateByPrimaryKey(AppStudyHistory record);

    List<AppStudyHistory> getMyStudyHistoryAll(@Param("userId") Long userId);

    @Select("SELECT study_history_id FROM app_study_history ORDER BY study_history_id DESC LIMIT 1")
    int getLastId();

    @Select("SELECT COUNT(*) AS count FROM app_study_history WHERE app_study_history.user_id = #{userId} AND app_study_history.general_id = #{generalId} AND app_study_history.order_id = #{orderId}")
    Integer getMyAlreadyStudyNum(Long userId, String generalId, String orderId);

    AppStudyHistory getLastStudyCourse(@Param("userId") Long userId);

    //    @Select("")
    AppStudyHistory isOnly(@Param("userId")Long userId, @Param("generalId")String generalId, @Param("orderId")String orderId, @Param("chapterName")String chapterName, @Param("videoName")String videoName);

}